package com.ctsi.flowable.idm.remote;

import com.ctsi.flowable.engine.service.FlowableService;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.idm.api.*;
import org.flowable.idm.engine.impl.IdmIdentityServiceImpl;

import java.util.List;

/**
 * @author: zhangjw
 * @Date: 2018/10/16 11:44
 * @Description:
 */
public class RemoteIdmIdentityServiceImpl extends IdmIdentityServiceImpl {

    private final FlowableService organiseServiceProxy;


    public RemoteIdmIdentityServiceImpl(FlowableService organiseServiceProxy) {
        this.organiseServiceProxy = organiseServiceProxy;
    }


    @Override
    public UserQuery createUserQuery() {
        return new RemoteUserQueryImpl(organiseServiceProxy);
    }

    @Override
    public GroupQuery createGroupQuery() {
        return new RemoteGroupQueryImpl(organiseServiceProxy);
    }


    @Override
    public List<Group> getGroupsWithPrivilege(String name) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support getGroupsWithPrivilege");
    }

    @Override
    public List<User> getUsersWithPrivilege(String name) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support getUsersWithPrivilege");
    }

    @Override
    public boolean checkPassword(String userId, String password) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support checkPassword");
    }

    @Override
    public User newUser(String userId) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support creating a new user");
    }

    @Override
    public void saveUser(User user) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support saving an user");
    }

    @Override
    public NativeUserQuery createNativeUserQuery() {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support native querying");
    }

    @Override
    public void deleteUser(String userId) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support deleting an user");
    }

    @Override
    public Group newGroup(String groupId) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support creating a new group");
    }

    @Override
    public NativeGroupQuery createNativeGroupQuery() {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support native querying");
    }

    @Override
    public void saveGroup(Group group) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support saving a group");
    }

    @Override
    public void deleteGroup(String groupId) {
        throw new FlowableException("CLOUD-PLATFORM remote identity service doesn't support deleting a group");
    }
}
